package com.zh.yqbj.util;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.ShearCaptcha;
import cn.hutool.core.collection.ListUtil;
import com.zh.yqbj.constant.CaptchaConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
public class CodeUtil {


    public List<String> getCode() {
        ShearCaptcha shearCaptcha = CaptchaUtil.createShearCaptcha(CaptchaConstant.CAPTCHA_WIDTH,
                CaptchaConstant.CAPTCHA_height, CaptchaConstant.CAPTCHA_CODE_COUNT,
                CaptchaConstant.CAPTCHA_THICKNESS);
        String code = shearCaptcha.getCode().toLowerCase();
        String imageBase64 =  new StringBuffer(CaptchaConstant.BASE_PREFIX).append(shearCaptcha.getImageBase64()).toString();
        log.info(code);
        log.info(imageBase64);
        return ListUtil.list(false, imageBase64, code);
    }
}
